package chat.network.http;//package chat.network.http;
//
//import com.alibaba.fastjson.JSON;
//import com.whu.zj.MyApplication;
//import com.whu.zj.R;
//
//import org.apache.http.HttpEntity;
//import org.apache.http.HttpResponse;
//import org.apache.http.client.HttpClient;
//import org.apache.http.client.methods.HttpPost;
//import org.apache.http.entity.ContentType;
//import org.apache.http.entity.mime.HttpMultipartMode;
//import org.apache.http.entity.mime.MultipartEntityBuilder;
//import org.apache.http.impl.client.DefaultHttpClient;
//
//import java.io.File;
//
///**
// * Created by Administrator on 2016/1/9.
// */
//public class SendPhoto {
//
//    File file;
//
//    SendMessage.Upload upload;
//
//    public File getFile() {
//        return file;
//    }
//
//    public SendMessage.Upload getUpload() {
//        return upload;
//    }
//
//    public SendPhoto(File file, SendMessage.Upload upload) {
//        this.file = file;
//        this.upload = upload;
//    }
//
//    // 上传
//    public boolean upload() throws Exception
//    {
//        HttpClient httpClient = new DefaultHttpClient();
//        String IP = MyApplication.share().getResources().getString(R.string.IP);
//        String url = "http://" + IP + "/chat/SendPhoto";
//        HttpPost post = new HttpPost(url);
//        MultipartEntityBuilder builder =  MultipartEntityBuilder.create();
//        builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
//
//        builder.addTextBody("data", JSON.toJSONString(upload), ContentType.TEXT_PLAIN.withCharset("utf-8"));
//
//        builder.addBinaryBody("file", file);
//
//        HttpEntity entity = builder.build();
//
//        post.setEntity(entity);
//
//        HttpResponse response = httpClient.execute(post);
//
//        if(response.getStatusLine().getStatusCode() == 200)
//        {
//            System.out.println("HttpUrlUpload(uploadFile)文件上传成功！！！");
//            return true;
//        }
//        System.out.println("HttpUrlUpload(uploadFile)文件上传失败！！！");
//        return false;
//    }
//
//
//}
